package net;

import message.Message;

import comunity.Community;
import comunity.Status;
import comunity.UserData;

public class MessageSender extends Sender {

	private MessageSender(Message message) {
		super(message);
	}

	@Override
	void handleResponse(int response) {
		if(response == Message.OFFLINE_RECEIVER)
			this.handleOfflineReceiver();
		else
			this.handleMessageSent();
	}

	private void handleMessageSent() {
		
	}

	private void handleOfflineReceiver() {
		
	}
	
	public static void sendMessage(String receiver, String text){
		UserData userData = UserData.obtainUserData();
		String username = userData.getUsername();
		int clientInputPort = OlivawPortsClient.getInputPort();
		Status status = userData.getStatus();
		
		Message message = new Message(username, receiver, text, clientInputPort, -1, -1, status);
		new Thread(new MessageSender(message)).start();
	}
	
	public static void sendBroadcastMessage(String text){
		MessageSender.sendMessage(Community.broadcastWildcard, text);
	}

}
